//
// Created by zcxsy on 2020/2/25.
//

#pragma warning(push, 0)
#include <glad/glad.h>
#include <GLFW/glfw3.h>
#pragma warning(pop)
#include <error.h>

struct GLFWwindow *initialize(void) {
    struct GLFWwindow *window;
    int loadResult;

    glfwInit();
    glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, 4);
    glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, 6);
    glfwWindowHint(GLFW_OPENGL_PROFILE, GLFW_OPENGL_CORE_PROFILE);

    window = glfwCreateWindow(800,
            600,
            "17343116",
            NULL,
            NULL);
    if (window == NULL) errorAndExit("Failed to create GLFW window");

    glfwMakeContextCurrent(window);

    loadResult = gladLoadGLLoader((GLADloadproc) glfwGetProcAddress);
    if (!loadResult) errorAndExit("Failed to initialize GLAD");

    return window;
}
